gskvulkanshader.c
gsk_private_vulkan_include_shaders = \
resources/vulkan/clip.frag.glsl \
+ resources/vulkan/clip.vert.glsl \
resources/vulkan/constants.glsl \
resources/vulkan/rounded-rect.glsl
gsk_private_vulkan_shaders = \
#version 420 core
-#include "constants.glsl"
+#define CLIP_ROUNDED_RECT
+#include "clip.vert.glsl"
layout(location = 0) in vec4 inRect;
layout(location = 1) in vec4 inTexRect;
vec2(1.0, 0.0),
vec2(1.0, 1.0) };
-vec4 intersect(vec4 a, vec4 b)
-{
- a = vec4(a.xy, a.xy + a.zw);
- b = vec4(b.xy, b.xy + b.zw);
- vec4 result = vec4(max(a.xy, b.xy), min(a.zw, b.zw));
- if (any (greaterThanEqual (result.xy, result.zw)))
- return vec4(0.0,0.0,0.0,0.0);
- return vec4(result.xy, result.zw - result.xy);
-}
-
void main() {
- vec4 rect = intersect(inRect, push.clip_bounds);
+ vec4 rect = clip (inRect);
vec2 pos = rect.xy + rect.zw * offsets[gl_VertexIndex];
gl_Position = push.mvp * vec4 (pos, 0.0, 1.0);
#version 420 core
-#include "constants.glsl"
+#define CLIP_RECT
+#include "clip.vert.glsl"
layout(location = 0) in vec4 inRect;
layout(location = 1) in vec4 inTexRect;
vec2(1.0, 0.0),
vec2(1.0, 1.0) };
-vec4 intersect(vec4 a, vec4 b)
-{
- a = vec4(a.xy, a.xy + a.zw);
- b = vec4(b.xy, b.xy + b.zw);
- vec4 result = vec4(max(a.xy, b.xy), min(a.zw, b.zw));
- if (any (greaterThanEqual (result.xy, result.zw)))
- return vec4(0.0,0.0,0.0,0.0);
- return vec4(result.xy, result.zw - result.xy);
-}
-
void main() {
- vec4 rect = intersect(inRect, push.clip_bounds);
+ vec4 rect = clip (inRect);
vec2 pos = rect.xy + rect.zw * offsets[gl_VertexIndex];
gl_Position = push.mvp * vec4 (pos, 0.0, 1.0);
#version 420 core
-#include "constants.glsl"
+#define CLIP_ROUNDED_RECT
+#include "clip.vert.glsl"
layout(location = 0) in vec4 inRect;
layout(location = 1) in vec4 inCornerWidths;
#define SLICE_BOTTOM_LEFT 6
#define SLICE_LEFT 7
-vec4 intersect(vec4 a, vec4 b)
-{
- a = vec4(a.xy, a.xy + a.zw);
- b = vec4(b.xy, b.xy + b.zw);
- vec4 result = vec4(max(a.xy, b.xy), min(a.zw, b.zw));
- if (any (greaterThanEqual (result.xy, result.zw)))
- return vec4(0.0,0.0,0.0,0.0);
- return vec4(result.xy, result.zw - result.xy);
-}
-
void main() {
int slice_index = gl_VertexIndex / 6;
int vert_index = gl_VertexIndex % 6;
break;
}
- rect = intersect (rect, push.clip_bounds);
+ rect = clip (rect);
vec2 pos;
if ((slice_index % 4) != 0 || (vert_index % 3) != 2)
pos = rect.xy + rect.zw * offsets[vert_index];
#version 420 core
-#include "constants.glsl"
+#define CLIP_RECT
+#include "clip.vert.glsl"
layout(location = 0) in vec4 inRect;
layout(location = 1) in vec4 inCornerWidths;
#define SLICE_BOTTOM_LEFT 6
#define SLICE_LEFT 7
-vec4 intersect(vec4 a, vec4 b)
-{
- a = vec4(a.xy, a.xy + a.zw);
- b = vec4(b.xy, b.xy + b.zw);
- vec4 result = vec4(max(a.xy, b.xy), min(a.zw, b.zw));
- if (any (greaterThanEqual (result.xy, result.zw)))
- return vec4(0.0,0.0,0.0,0.0);
- return vec4(result.xy, result.zw - result.xy);
-}
-
void main() {
int slice_index = gl_VertexIndex / 6;
int vert_index = gl_VertexIndex % 6;
break;
}
- rect = intersect (rect, push.clip_bounds);
+ rect = clip (rect);
vec2 pos;
if ((slice_index % 4) != 0 || (vert_index % 3) != 2)
pos = rect.xy + rect.zw * offsets[vert_index];
--- /dev/null
+#include "constants.glsl"
+
+#ifndef _CLIP_
+#define _CLIP_
+
+vec4 intersect(vec4 a, vec4 b)
+{
+ a = vec4(a.xy, a.xy + a.zw);
+ b = vec4(b.xy, b.xy + b.zw);
+ vec4 result = vec4(max(a.xy, b.xy), min(a.zw, b.zw));
+ if (any (greaterThanEqual (result.xy, result.zw)))
+ return vec4(0.0,0.0,0.0,0.0);
+ return vec4(result.xy, result.zw - result.xy);
+}
+
+#ifdef CLIP_ROUNDED_RECT
+vec4 clip(vec4 rect)
+{
+ /* rounded corner clipping is done in fragment shader */
+ return intersect(rect, push.clip_bounds);
+}
+#elif defined(CLIP_RECT)
+vec4 clip(vec4 rect)
+{
+ return intersect(rect, push.clip_bounds);
+}
+#elif defined(CLIP_NONE)
+vec4 clip(vec4 rect)
+{
+ return rect;
+}
+#else
+#error "No clipping define given. Need CLIP_NONE, CLIP_RECT or CLIP_ROUNDED_RECT"
+#endif
+
+#endif
#version 420 core
-#include "constants.glsl"
+#define CLIP_ROUNDED_RECT
+#include "clip.vert.glsl"
layout(location = 0) in vec4 inRect;
layout(location = 1) in vec4 inColor;
vec2(1.0, 1.0) };
void main() {
- vec2 pos = inRect.xy + inRect.zw * offsets[gl_VertexIndex];
+ vec4 rect = clip (inRect);
+
+ vec2 pos = rect.xy + rect.zw * offsets[gl_VertexIndex];
gl_Position = push.mvp * vec4 (pos, 0.0, 1.0);
outPos = pos;
outColor = inColor;
#version 420 core
-#include "constants.glsl"
+#define CLIP_RECT
+#include "clip.vert.glsl"
layout(location = 0) in vec4 inRect;
layout(location = 1) in vec4 inColor;
vec2(1.0, 0.0),
vec2(1.0, 1.0) };
-vec4 intersect(vec4 a, vec4 b)
-{
- a = vec4(a.xy, a.xy + a.zw);
- b = vec4(b.xy, b.xy + b.zw);
- vec4 result = vec4(max(a.xy, b.xy), min(a.zw, b.zw));
- if (any (greaterThanEqual (result.xy, result.zw)))
- return vec4(0.0,0.0,0.0,0.0);
- return vec4(result.xy, result.zw - result.xy);
-}
-
void main() {
- vec4 rect = intersect(inRect, push.clip_bounds);
+ vec4 rect = clip (inRect);
vec2 pos = rect.xy + rect.zw * offsets[gl_VertexIndex];
gl_Position = push.mvp * vec4 (pos, 0.0, 1.0);
#version 420 core
-#include "constants.glsl"
+#define CLIP_ROUNDED_RECT
+#include "clip.vert.glsl"
layout(location = 0) in vec4 inRect;
layout(location = 1) in vec4 inTexRect;
vec2(1.0, 0.0),
vec2(1.0, 1.0) };
-vec4 intersect(vec4 a, vec4 b)
-{
- a = vec4(a.xy, a.xy + a.zw);
- b = vec4(b.xy, b.xy + b.zw);
- vec4 result = vec4(max(a.xy, b.xy), min(a.zw, b.zw));
- if (any (greaterThanEqual (result.xy, result.zw)))
- return vec4(0.0,0.0,0.0,0.0);
- return vec4(result.xy, result.zw - result.xy);
-}
-
void main() {
- vec4 rect = intersect(inRect, push.clip_bounds);
+ vec4 rect = clip (inRect);
vec2 pos = rect.xy + rect.zw * offsets[gl_VertexIndex];
gl_Position = push.mvp * vec4 (pos, 0.0, 1.0);
#version 420 core
-#include "constants.glsl"
+#define CLIP_RECT
+#include "clip.vert.glsl"
layout(location = 0) in vec4 inRect;
layout(location = 1) in vec4 inTexRect;
vec2(1.0, 0.0),
vec2(1.0, 1.0) };
-vec4 intersect(vec4 a, vec4 b)
-{
- a = vec4(a.xy, a.xy + a.zw);
- b = vec4(b.xy, b.xy + b.zw);
- vec4 result = vec4(max(a.xy, b.xy), min(a.zw, b.zw));
- if (any (greaterThanEqual (result.xy, result.zw)))
- return vec4(0.0,0.0,0.0,0.0);
- return vec4(result.xy, result.zw - result.xy);
-}
-
void main() {
- vec4 rect = intersect(inRect, push.clip_bounds);
+ vec4 rect = clip (inRect);
vec2 pos = rect.xy + rect.zw * offsets[gl_VertexIndex];
gl_Position = push.mvp * vec4 (pos, 0.0, 1.0);
#version 420 core
-#include "constants.glsl"
+#define CLIP_ROUNDED_RECT
+#include "clip.vert.glsl"
struct ColorStop {
float offset;
}
void main() {
- vec2 pos = inRect.xy + inRect.zw * offsets[gl_VertexIndex];
+ vec4 rect = clip (inRect);
+ vec2 pos = rect.xy + rect.zw * offsets[gl_VertexIndex];
gl_Position = push.mvp * vec4 (pos, 0.0, 1.0);
outPos = pos;
outGradientPos = get_gradient_pos (pos);
#version 420 core
-#include "constants.glsl"
+#define CLIP_RECT
+#include "clip.vert.glsl"
struct ColorStop {
float offset;
}
void main() {
- vec2 pos = inRect.xy + inRect.zw * offsets[gl_VertexIndex];
+ vec4 rect = clip (inRect);
+ vec2 pos = rect.xy + rect.zw * offsets[gl_VertexIndex];
gl_Position = push.mvp * vec4 (pos, 0.0, 1.0);
outGradientPos = get_gradient_pos (pos);
outRepeating = inRepeating;
#version 420 core
-#include "constants.glsl"
+#define CLIP_NONE
+#include "clip.vert.glsl"
struct ColorStop {
float offset;
vec2(1.0, 0.0),
vec2(1.0, 1.0) };
-vec4 intersect(vec4 a, vec4 b)
-{
- a = vec4(a.xy, a.xy + a.zw);
- b = vec4(b.xy, b.xy + b.zw);
- vec4 result = vec4(max(a.xy, b.xy), min(a.zw, b.zw));
- if (any (greaterThanEqual (result.xy, result.zw)))
- return vec4(0.0,0.0,0.0,0.0);
- return vec4(result.xy, result.zw - result.xy);
-}
-
float
get_gradient_pos (vec2 pos)
{
}
void main() {
- vec4 rect = intersect(inRect, push.clip_bounds);
+ vec4 rect = clip (inRect);
vec2 pos = rect.xy + rect.zw * offsets[gl_VertexIndex];
gl_Position = push.mvp * vec4 (pos, 0.0, 1.0);
outGradientPos = get_gradient_pos (pos);